'这里是代码处理模块

Sub 处理多行注解(ByRef ci As Long, C代码 As String, B代码 As String)
   Dim ff As Long = InStr(ci + 2, C代码, "*/")
   If ff = 0 Then ff = Len(C代码) -1
   Dim ss As String = Mid(C代码, ci + 1, ff - ci)
   dim sci as long =ci 
   ci = ff + 1
   Dim pp() As String
   vbSplit(ss, vbCrLf, pp())
   Dim i As Long
   For i = 0 To UBound(pp)
      pp(i) = "'" & 翻译英文注解(pp(i))
   Next
   新增翻译列表("多注",sci,ss,Len(B代码)+1,YF_Join(pp(), vbCrLf)) 
   B代码     &= YF_Join(pp(), vbCrLf)
End Sub
Sub 处理单行注解(ByRef ci As Long, C代码 As String, B代码 As String)
   '// Platform specific defines to handle GetApplicationDirectory()
   Dim ff As Long = InStr(ci + 2, C代码, vbCrLf)
   If ff = 0 Then ff = Len(C代码) + 1 
   Dim ss As String = Mid(C代码, ci + 2, ff - ci -2)
   Dim tss As String =Mid(C代码, ci , ff - ci ) 
   Dim sci As Long =ci
   ci    = ff + 1
   ss = "'" & 翻译英文注解(ss)
   'If Len(B代码)>2 And Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
   新增翻译列表("单注",sci,tss,Len(B代码)+1,ss & vbCrLf) 
   B代码 &= ss & vbCrLf 
   
End Sub
Sub 处理引用(ByRef ci As Long, C代码 As String, B代码 As String)
   '#include "raylib.h"        // Declares module functions
   Dim ff As Long = InStr(ci + 2, C代码, vbCrLf)
   If ff = 0 Then ff = Len(C代码) +1 
   Dim ss As String = Mid(C代码, ci, ff - ci)
   Dim sci As Long =ci ,sc代码 As String 
   ci = ff - 1   
   sc代码 =ss
   ss = YF_Replace(ss, "<", """")
   ss = YF_Replace(ss, ">", """")
   ss = YF_Replace(ss, ".h""", ".bi""")
   直接替换关键词(ss)
   处理单行中有注解(ss)
   'If Len(B代码)>2 And Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
   新增翻译列表("引用",sci,sc代码,Len(B代码)+1,ss ) 
   B代码 &=ss 
End Sub
Sub 处理直接一行(ByRef ci As Long, C代码 As String, B代码 As String)
   Dim ff As Long = InStr(ci + 2, C代码, vbCrLf)
   If ff = 0 Then ff = Len(C代码) + 1 
   Dim ss As String = Mid(C代码, ci, ff - ci)
   Dim sci As Long =ci ,sc代码 As String =ss 
   ci = ff - 1
   直接替换关键词(ss)
   处理单行中有注解(ss)
   'If Len(B代码)>2 And Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
   新增翻译列表("直接",sci,sc代码,Len(B代码)+1,ss ) 
   B代码 &= ss
End Sub
Sub 处理类定义(ByRef ci as Long, C代码 as String, B代码 as String, ByVal 父类名 as String, 返回子类名 as String)
   'struct { int x; int y; } Point;  struct CoreData {
   Dim ff As Long = InStr代码查找(ci + 6, C代码, "{")
   If ff = 0 Then ff = Len(C代码) + 1
   Dim ff2 As Long = InStr代码查找(ci + 6, C代码, ";")
   If ff2 = 0 Then ff2 = Len(C代码) + 1
   Dim ss As String = Trim(Mid(C代码, ci + 6, ff - ci -6), Any Chr(32, 13, 10))
   If ff2 < ff Then '遇到;先，就表示是 定义
      Dim sci As Long = ci, sc代码 As String = Mid(C代码, ci, ff2 - ci + 1)
      ss = Trim(Mid(C代码, ci + 6, ff2 - ci -6), Any Chr(32, 13, 10))
      ci = ff2 + 1
      ss = 处理参数列表(ss, "")
      变量列表连续变量(ss)
      直接替换关键词(ss)
      ss  = YF_Replace(ss, ")", " -1)")
      ff2 = InStr(ci, C代码, vbCrLf)
      Dim 注解 As String
      If ff2 Then
         注解   = Mid(C代码, ci, ff2 - ci)
         sc代码 &= 注解
         处理单行中有注解(注解)
         ci   = ff2 + 1
         注解 &= vbCrLf
      End If
      
      'If Len(B代码)>2 And Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
      If 父类名 = "" Then 新增翻译列表("类定", sci, sc代码, Len(B代码) + 1, "Dim " & ss & 注解)
      B代码 &= "Dim " & ss & 注解
      Return
   End If
   Dim sci As Long = ci, sc代码 As String = Mid(C代码, ci, ff - ci)
   ss = Trim(Mid(C代码, ci + 6, ff - ci -6), Any Chr(32, 13, 10))
   ci = ff + 1
   Dim 类名   As String = ss
   Dim 尾巴名 As String, 尾巴注解 As String
   ff = InStr代码查找结束配对(ci, C代码)
   If ff = 0 Then ff = Len(C代码) + 1
   ss     = Mid(C代码, ci, ff - ci) '这是中间代码
   sc代码 &= Mid(C代码, ci, ff - ci + 1)
   ci     = ff + 1
   ff     = InStr(ci, C代码, ";")
   If ff Then
      尾巴名 = Trim(Mid(C代码, ci, ff - ci), Any Chr(32, 13, 10))
      sc代码 &= Mid(C代码, ci, ff - ci + 1)
      ci     = ff + 1
   End If
   ff = InStr代码查找注解(ci, C代码)
   If ff Then
      Dim ff2 As Long = InStr(ff + 2, C代码, vbCrLf)
      If ff2 = 0 Then ff2 = Len(C代码) + 1
      尾巴注解 = Trim(Mid(C代码, ff + 2, ff2 - ff -2), Any Chr(32, 13, 10))
      sc代码   &= Mid(C代码, ff, ff2 - ff)
      尾巴注解 = "' " & 翻译英文注解(尾巴注解) & vbCrLf
      ci       = ff2 + 1
   End If
   If 类名 = "" Then 类名 = 尾巴名
   'SaveFileStr(App.Path & "x" & 类名 & ".txt",ss)
   Dim 类内容 As String, sti As Long = 1, 空 As Long
   For si As Long = 1 To Len(ss)
      If Mid(ss, si, 7) = "struct " Or Mid(ss, si, 7) = "struct{" Then '类中类
         ff = InStr首字符查找(si + 6, ss, "", 0)
         if Mid(ss, ff, 1) = "{" then
            Dim 子类名 As String
            处理类定义(si, ss, B代码, 类名, 子类名)
            If Len(类内容) Then 类内容 &= vbCrLf
            类内容 &= 子类名 & " As " & 类名 & "_" & 子类名
            sti    = si
            空     = 0
         End If
         Continue For
      End If
      If Mid(ss, si, 1) = ";" Then
         If Len(类内容) Then 类内容 &= vbCrLf
         Dim 参数 As String = Mid(ss, sti, si - sti)
         参数=Trim(参数,Any Chr(32,10,13))
         参数 = 处理参数列表(参数, "")
         变量列表连续变量(参数)
         直接替换关键词(参数)
         类内容 &= Space(空) & 参数 ' 变量定义处理(Mid(ss, sti, si - sti))
         sti    = si + 1
         空     = 0
         Continue For
      End If
      If Mid(ss, si, 2) = vbCrLf Then
         'If Len(类内容) Then 类内容 &= vbCrLf
         si += 1
         空 = 0
         Continue For
      End If
      If Mid(ss, si, 2) = "//" Then
         ff = InStr(si + 2, ss, vbCrLf)
         If ff = 0 Then ff = Len(ss)
         Dim tt As String = Mid(ss, si + 2, ff - si -2)
         If tt <> "" Then 类内容 &= Space(空) & "'" & 翻译英文注解(tt)
         si  = ff + 2
         sti = si
         空  = 0
         Continue For
      End If
      If Mid(ss, si, 1) = " " Then 空 += 1
   Next
   Dim sbi As Long = Len(B代码) + 1, sb代码 As String
   sb代码 = "Type " & IIf(Len(父类名), 父类名 & "_", "") & 类名 & vbCrLf & 类内容 & vbCrLf & Space(空) & "End Type"
   B代码  &= sb代码
   
   If 类名 <> 尾巴名 And 尾巴名 <> "" Then
      'If Len(B代码)>2 And Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
      B代码  &= vbCrLf & "Type " & 尾巴名 & " As " & 类名
      sb代码 &= vbCrLf & "Type " & 尾巴名 & " As " & 类名
   End If
   If 父类名 = "" Then 新增翻译列表("类", sci, sc代码, sbi, sb代码)
   返回子类名 = 类名
   
End Sub
Sub 处理枚举定义(ByRef ci As Long, C代码 As String, B代码 As String)
   'typedef enum {
   Dim ff As Long = InStr首字符查找(ci + 4, C代码, "", 0)
   If ff = 0 Then
      未处理代码处理(ci, B代码, Mid(C代码, ci))
      ci = Len(C代码) + 1
      Return
   End If
   Dim sci  As Long = ci, sc代码 As String = Mid(C代码, ci, ff - ci)
   Dim 注解 As String
   If Mid(C代码, ff, 2) = "//" Then
      ff = InStr(ff + 2, C代码, vbCrLf)
      If ff = 0 Then ff = Len(C代码) + 1
      注解   = Mid(C代码, ci + 4, ff - ci -4) & vbCrLf
      sc代码 &= 注解 & vbCrLf
      处理单行中有注解(注解)
      ci = ff + 2
      ff = InStr首字符查找(ci, C代码, "", 0)
      If ff = 0 Then
         未处理代码处理(ci, B代码, sc代码)
         ci = Len(C代码) + 1
         Return
      End If
      
   End If
   ci = ff
   Dim ss As String
   ff = InStr代码查找(ci, C代码, ";", 1)
   If ff = 0 Then ff = Len(C代码) + 1
   ss     = Trim(Mid(C代码, ci, ff - ci), Any Chr(32, 13, 10))
   sc代码 &= Mid(C代码, ci, ff - ci)
   ci     = ff
   If InStr(ss, "{") = 0 Then
      ss = 处理参数列表(ss, "")
      直接替换关键词(ss)
      新增翻译列表("枚定", sci, sc代码, Len(B代码) + 1, "Dim " & ss)
      B代码 &= "Dim " & ss
      Return
   End If
   
   Dim 类名   As String
   Dim 尾巴名 As String, 尾巴注解 As String
   ff     = InStr空字符查找(1, ss, 0)
   类名 = Trim(Left(ss, ff -1), Any Chr(32, 13, 10))
   If 类名="{" Then 类名=""
   ff     = InStr(ss, "{")
   ss     = Trim(Mid(ss, ff + 1), Any Chr(32, 13, 10))
   ff     = InStr(ss, "}")
   尾巴名 = Trim(Mid(ss, ff + 1), Any Chr(32, 13, 10))
   ss     = Trim(Left(ss, ff -1), Any Chr(32, 13, 10)) '这是中间代码
   ff     = InStr代码查找注解(ci, C代码)
   If ff Then
      Dim ff2 As Long = InStr(ff + 2, C代码, vbCrLf)
      If ff2 = 0 Then ff2 = Len(C代码) + 1
      尾巴注解 = Trim(Mid(C代码, ff + 2, ff2 - ff -2), Any Chr(32, 13, 10))
      尾巴注解 = "' " & 翻译英文注解(尾巴注解) & vbCrLf
      ci       = ff2 - 1
   End If
   If 类名 = "" Then 类名 = 尾巴名
   'SaveFileStr(App.Path & "x" & 类名 & ".txt",ss)
   Dim 类内容 As String, sti As Long = 1, 空 As Long
   For si As Long = 1 To Len(ss)
      If Mid(ss, si, 1) = "," Or si = Len(ss) Then
         If Len(类内容) > 0 And Right(类内容, 2) <> vbCrLf Then 类内容 &= vbCrLf
         If si = Len(ss) Then si += 1
         Dim tt As String = Mid(ss, sti, si - sti)
         If Left(tt,2)=vbCrLf Then tt=Mid(tt,3)
         直接替换关键词(tt)
         类内容 &= tt
         sti    = si + 1
         空     = 0
         Continue For
      End If
      If Mid(ss, si, 2) = vbCrLf Then
         If Len(类内容) > 0 And Right(类内容, 2) <> vbCrLf Then 类内容 &= vbCrLf
         si += 1
         空 = 0
         Continue For
      End If
      If Mid(ss, si, 2) = "//" Then
         Dim tt As String = Trim(Mid(ss, sti, si - sti), Any Chr(32, 13, 10))
         If tt <> "" Then
            If Len(类内容) > 0 And Right(类内容, 2) <> vbCrLf Then 类内容 &= vbCrLf
            If Left(tt,2)=vbCrLf Then tt=Mid(tt,3)
            直接替换关键词(tt)
            类内容 &= tt
         End If
         ff = InStr(si + 2, ss, vbCrLf)
         If ff = 0 Then ff = Len(ss)
         tt = Mid(ss, si + 2, ff - si -2)
         If tt <> "" Then 类内容 &= Space(空) & "'" & 翻译英文注解(tt)
         si  = ff + 2
         sti = si
         空  = 0
         Continue For
      End If
      If Mid(ss, si, 1) = " " Then 空 += 1
   Next
   'Print 类内容[0],类内容[1]
   If Left(类内容, 2) = vbCrLf Then 类内容 = Mid(类内容, 3)
   'If Len(B代码)>2 And Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
   Dim sbi As Long = Len(B代码) + 1, sb代码 As String
   sb代码 = "Enum " & 类名 & vbCrLf & 类内容 & vbCrLf & Space(空) & "End Enum" & vbCrLf
   B代码  &= sb代码
   If 类名 <> 尾巴名 And 尾巴名 <> "" Then
      'If Len(B代码)>2 And Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
      B代码  &= "Dim shared " & 尾巴名 & " As " & 类名
      sb代码 &= "Dim shared " & 尾巴名 & " As " & 类名
   End If
   新增翻译列表("枚举", sci, sc代码, sbi, sb代码)
   
End Sub
Sub 处理函数定义(ByRef ci As Long, C代码 As String, B代码 As String)
   'typedef void (*TraceLogCallback)(int logLevel, const char *text, va_list args);  // Logging: Redirect trace log messages
   'typedef unsigned int u32;
   Dim ff As Long = InStr代码查找(ci + 6, C代码, ";")
   If ff = 0 Then ff = Len(C代码) + 1
   Dim sci As Long   = ci, sc代码 As String = Mid(C代码, ci, ff - ci)
   Dim ss  As String = Trim(sc代码, Any Chr(32, 13, 10))
   ci = ff + 1
   ff = InStr(ci, C代码, vbCrLf)
   Dim 注解 As String
   If ff Then
      注解   = Mid(C代码, ci, ff - ci)
      sc代码 &= 注解
      处理单行中有注解(注解)
      ci   = ff + 1
      注解 &= vbCrLf
   End If
   ff     = InStrRev(C代码, "typedef", sci)
   sc代码 = Mid(C代码, ff, sci - ff) & sc代码
   sci    = ff
   '函数需要从右到左分析才可以
   ff = InStr代码查找倒查(0, ss, ")")
   if ff = 0 then
      ss = 处理参数列表(ss, "")
      直接替换关键词(ss)
      新增翻译列表("别名", sci, sc代码, Len(B代码) + 1, "Type " & ss & 注解)
      B代码 &= "Type " & ss & 注解
      Return
   End If
   ss = Left(ss, ff -1)
   Dim 参数列表 As String
   ff = InStr代码查找倒查(0, ss, "(")
   If ff = 0 Then ff = 1
   参数列表 = Mid(ss, ff + 1)
   参数列表 = 处理参数列表(参数列表, "ByVal ")
   ss       = Trim(Left(ss, ff -1), Any Chr(32, 13, 10)) '头部
   Dim 函数名 As String, 函数定义 As String, 返回类型 As String, rr As String, 无符号 As String, 不可修改 As String
   Do
      ff = InStrRev(ss, " ")
      If ff = 0 Then
         rr = ss
      Else
         rr = Trim(Mid(ss, ff + 1), Any Chr(32, 13, 10))
         ss = Trim(Left(ss, ff -1), Any Chr(32, 13, 10))
      end if
      If 函数名 = "" Then
         函数名 = rr
      Else
         If 返回类型 = "" Then
            返回类型 = rr
         Else
            If rr = "unsigned" Then 无符号   = "U"
            If rr = "const"    Then 不可修改 = "Const "
         End If
      End If
      If ff = 0 Then Exit Do
   Loop
   Do
      If Left(函数名, 1) <> "*" Then Exit Do
      函数名 = Mid(函数名, 2)
      If 返回类型 = "char" Then 返回类型 = "ZString"
      返回类型 &= " Ptr"
   Loop
   
   If Left(函数名, 1) = "("  Then 函数名 = Mid(函数名, 2)
   If Left(函数名, 1) = "*"  Then 函数名 = Mid(函数名, 2)
   If Right(函数名, 1) = ")" Then 函数名 = Left(函数名, Len(函数名) -1)
   If 返回类型 = "void" Then
      返回类型 = ""
      函数定义 = " As Sub("
   Else
      函数定义 = " As Function("
   End If
   If 返回类型 <> "" Then
      直接替换关键词(返回类型)
      返回类型 = "As " & 不可修改 & 无符号 & 返回类型
   End If
   'If Right(B代码,2)<>vbCrLf Then B代码 &= vbCrLf
   新增翻译列表("函别", sci, sc代码, Len(B代码) + 1, "Type  " & 函数名 & 函数定义 & 参数列表 & ")" & 返回类型 & 注解)
   B代码 &= "Type  " & 函数名 & 函数定义 & 参数列表 & ")" & 返回类型 & 注解
   
End Sub
Sub 处理静态变量定义(ByRef ci As Long, C代码 As String, B代码 As String)
   'static bool automationEventRecording = false;               // Recording automation events flag
   'static void ResetStar(Star *s);  函数定义
   'static void ResetStar(Star *s){ ... } 函数体
   Dim ff As Long = InStr代码查找(ci + 6, C代码, ";")
   If ff = 0 Then ff = Len(C代码) + 1
   Dim ff2 As Long = InStr代码查找(ci + 6, C代码, "{")
   If ff2 = 0 Then ff2 = Len(C代码) + 1
   If ff2 < ff Then
      '这是函数，并不是定义
      ci += 6
      Return
   End If
   
   Dim sci As Long   = ci, sc代码 As String = Mid(C代码, ci, ff - ci)
   Dim ss  As String = Trim(Mid(C代码, ci + 7, ff - ci -7), Any Chr(32, 13, 10))
   ci = ff + 1
   ff = InStr代码查找(1, ss, "=", 1)
   Dim 等于后面 As String
   If ff Then
      等于后面 = Mid(ss, ff)
      ss       = Left(ss, ff -1)
   End If
   ff = InStr首字符查找倒查(0, ss, ")", 0)
   'Print ff,ss
   If ff > 0 And 等于后面 = "" Then 
      ci = sci + 6     '大概率不是定义
     Return 
   End If       
   ff = InStr(ci, C代码, vbCrLf)
   Dim 注解 As String
   If ff Then
      注解   = Mid(C代码, ci, ff - ci)
      sc代码 &= 注解
      处理单行中有注解(注解)
      ci   = ff + 1
      注解 &= vbCrLf
   End If
   
   
   ss       = 处理参数列表(ss, "")
   等于后面 = C代码转换B代码(等于后面)
   'If Right(B代码,2)<>vbCrLf Then B代码 &= vbCrLf
   新增翻译列表("静态", sci, sc代码, Len(B代码) + 1, "Static " & ss & 等于后面 & 注解)
   B代码 &= "Static " & ss & 等于后面 & 注解
   
End Sub
Sub 处理extern(ByRef ci As Long, C代码 As String, B代码 As String)
   'extern "C" {
   'extern int d = 3, f = 5;    // d 和 f 的声明与初始化
   Dim ff As Long = InStr首字符查找(ci + 7, C代码, """", 0)
   If ff = 0 Then ff = InStr首字符查找(ci + 7, C代码, "'", 0)
   If ff Then
      ff = InStr代码查找(ci + 7, C代码, "{")
      If ff = 0 Then ff = Len(C代码) + 1
      Dim sci As Long   = ci, sc代码 As String = Mid(C代码, ci, ff - ci + 1)
      Dim ss  As String = Trim(Mid(C代码, ci, ff - ci), Any Chr(32, 13, 10))
      ci = ff + 1
      ff = InStr(ci, C代码, vbCrLf)
      Dim 注解 As String
      If ff Then
         注解   = Mid(C代码, ci, ff - ci)
         sc代码 &= Mid(C代码, ci, ff - ci)
         处理单行中有注解(注解)
         ci   = ff + 1
         注解 &= vbCrLf
      End If
      
      'If Right(B代码,2)<>vbCrLf Then B代码 &= vbCrLf
      新增翻译列表("外部", sci, sc代码, Len(B代码) + 1, ss & 注解)
      B代码 &= ss & 注解
   Else
      ' '外部变量定义
      ff = InStr代码查找(ci + 6, C代码, ";")
      If ff = 0 Then ff = Len(C代码) + 1
      Dim sci As Long   = ci, sc代码 As String = Mid(C代码, ci, ff - ci)
      Dim ss  As String = Trim(Mid(C代码, ci + 7, ff - ci -7), Any Chr(32, 13, 10))
      ci = ff + 1
      ss = 处理参数列表(ss, "")
      dim aff as long  = 1
      Dim bb   As String, pss  As String
      Dim 等号 As String, 类型 As String, s类型 As String, 变量名 As String
      Do
         aff = InStr代码查找(1, ss, ",", 1)
         If aff Then
            bb = Left(ss, aff -1)
            ss = Mid(ss, aff + 1)
         Else
            bb = ss
            ss = ""
         End If
         ff = InStr代码查找(1, bb, "=", 1)
         If ff Then
            等号 = Mid(bb, ff)
            bb   = Left(bb, ff -1)
         Else
            等号 = ""
         End If
         ff = InStr代码查找(1, bb, " As ", 1)
         If ff Then
            类型  = Mid(bb, ff + 4)
            s类型 = 类型
            bb=Left(bb,ff-1)
         Else
            类型 = s类型
         End If
         ff = InStr代码查找倒查(0, RTrim(bb), " ")
         变量名 = Mid(bb, ff + 1)
         bb = Left(bb, ff -1)
         If Len(pss) Then pss &= ","
         pss &= bb & 变量名 & " Alias """ & 变量名 & """ As " & 类型 & 等号
         
         If aff = 0 Then Exit Do
      Loop
      ss = pss
      
      直接替换关键词(ss)
      ss = YF_Replace(ss, ")", " -1)")
      
      新增翻译列表("外变", sci, sc代码, Len(B代码) + 1, "Extern " & ss )
      B代码 &= "Extern " & ss 
      
   end if
End Sub
Sub 处理结尾(ByRef ci As Long, C代码 As String, B代码 As String, 配对语句 As String)
   '  }
   Dim ff As Long = InStrRev(配对语句, "End ")
   If ff Then
      Dim pp As String = Mid(配对语句, ff)
      If pp = "End If" Or pp = "End If*" Then
         Dim ff2 As Long = InStr首字符查找(ci + 1, C代码, "", 0)
         If Mid(C代码, ff2, 2) = "//" Then
            ff2 = InStr(ff2 + 1, C代码, vbCrLf)
            If ff2 = 0 Then ff2 = Len(C代码)
            ff2 = InStr首字符查找(ff2 + 2, C代码, "", 0)
         End If
         If Mid(C代码, ff2, 2) = "/*" Then
            ff2 = InStr(ff2 + 2, C代码, "*/")
            If ff2 = 0 Then ff2 = Len(C代码)
            ff2 = InStr首字符查找(ff2 + 2, C代码, "", 0)
         End If
         If Mid(C代码, ff2, 5) = "else " Or Mid(C代码, ff2, 5) = "else{" Or Mid(C代码, ff2, 5) = "else;" Or Mid(C代码, ff2, 5) = "else" & vbCr Then
            Dim cc As Long = ff2 + 4
            ff = InStr代码查找(cc, C代码, ";", 1) '遇到好多  else x += (COLOR_SIZE*2 + MARGIN_SIZE);  就结束if 的 后面没 } 配对了。
            If ff = 0 Then ff = Len(C代码)
            ff2 = InStr代码查找(cc, C代码, "{", 1)
            If ff2 = 0  Then ff2      = Len(C代码)
            If ff < ff2 Then 配对语句 &= "*"
            Return
         End If
      End If
      If pp = "End Select" Then
         Dim ff2 As Long = InStr首字符查找(ci + 1, C代码, "break;", 0)
         If ff2 Then
            ci = ff2 + 6
            Return
         End If
         
      end if
      配对语句 = Left(配对语句, ff -1)
      Dim sci As Long = ci, sc代码 As String = "}"
      Dim kpp As String
      Do
         If Right(pp, 1) <> "*" Then Exit Do '有欠
         pp = Left(pp, Len(pp) -1)
         If pp = "End Wend" Then pp  = "Wend"
         If pp = "End Next" Then pp  = "Next"
         If kpp <> ""       Then kpp &= vbCrLf
         kpp &= pp
         ff  = InStrRev(配对语句, "End ")
         If ff = 0 Then Exit Do
         pp       = Mid(配对语句, ff)
         配对语句 = Left(配对语句, ff -1)
      Loop
      If kpp <> ""       Then pp = kpp & vbCrLf & pp
      If pp = "End Wend" Then pp = "Wend"
      If pp = "End Next" Then pp = "Next"
      ff = InStr首字符查找(ci + 1, C代码, "//", 0)
      Dim 注解 As String
      If ff Then
         ff = InStr(ff + 2, C代码, vbCrLf)
         If ff = 0 Then ff = Len(C代码) + 1
         注解 = Mid(C代码, ci + 1, ff - ci -1)
         处理单行中有注解(注解)
         ci   = ff + 1
         注解 &= vbCrLf
      End If
      
      新增翻译列表("}", sci, sc代码, Len(B代码) + 1, pp & 注解)
      If Right(RTrim(B代码), 2) <> vbCrLf Then B代码 &= vbCrLf
      B代码 &= pp & 注解
      
   Else
      未处理代码处理(ci, B代码, "}")
   End If
   
End Sub

Sub 处理语句结束符号(ByRef ci As Long, C代码 As String, B代码 As String, 未处理代码 As String)
   ';
   Dim ff  As Long
   Dim ss  As String = 未处理代码
   Dim sci As Long   = ci - Len(ss), sc代码 As String = ss
   
   未处理代码 = ""
   ff         = InStr代码查找倒查(0, ss, "=", 1)
   Dim 等于后面 As String
   If ff Then
      Dim xx As String = Mid(ss, ff -2, 2)
      等于后面 = Trim(Mid(ss, ff + 1), Any Chr(13, 10))
      If xx = "<<" Then
         xx = "Shl="
         ff -= 2
      ElseIf xx = ">>" Then
         xx = "Shr="
         ff -= 2
      Else
         xx = Mid(ss, ff -1, 1)
         If InStr("+-*/%&^|><", xx) > 0 Then
            If xx = "%" Then
               xx = "Mod="
            ElseIf xx = "&" Then
               xx = "And="
            ElseIf xx = "^" Then
               xx = "Xor="
            ElseIf xx = "|" Then
               xx = "Or="
            ElseIf xx = ">" Then
               xx = ">="
            ElseIf xx = "<" Then
               xx = "<="
            Else
               xx &= "="
            End If
            ff -= 1
         Else
            xx = "="
         End If
      End If
      等于后面 &= ";"
      'Print 等于后面
      等于后面 = C代码转换B代码(等于后面) '
      等于后面 = " " & xx & " " & 等于后面
      ss       = Left(ss, ff -1)
   End If
   
   '函数需要从右到左分析才可以
   ff = InStr首字符查找倒查(0, ss, ")", 0)
   If ff Then
      ss = Left(ss, ff -1)
   Else
      '那么就是函数定义
      Dim 前面字符 As String
      前面字符 = LTrim(ss, Any Chr(32, 13, 10))
      ff       = Len(ss) - Len(前面字符)
      If ff Then 前面字符 = Left(ss, ff) Else 前面字符 = ""
      'Print ss
      ss = 处理参数列表(ss, "")
      
      'If Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
      If InStr(ss, " As ") = 0 Then
         If Right(ss, 2) = "++" Then ss = Left(ss, Len(ss) -2) & " +=1"
         强制类型转换(ss)
         直接替换关键词(ss)
         新增翻译列表("语句", sci, sc代码, Len(B代码) + 1, 前面字符 & ss & 等于后面)
         B代码 &= 前面字符 & ss & 等于后面 '通常的赋值
      Else
         变量列表连续变量(ss)
         直接替换关键词(ss)
         'ss = YF_Replace(ss, ")", " -1)")
         新增翻译列表("变量", sci, sc代码, Len(B代码) + 1, 前面字符 & "Dim " & ss & 等于后面)
         B代码 &= 前面字符 & "Dim " & ss & 等于后面
      End If
      Return
   End If
   Dim 参数列表 As String
   ff = InStr代码查找倒查(0, ss, "(")
   If ff = 0 Then ff = 1
   参数列表 = Mid(ss, ff + 1)
   Dim 前面字符 As String
   ss       = Left(ss, ff -1)
   前面字符 = ss
   Dim 函数声明 As String
   ff = Len(ss) - Len(LTrim(前面字符, Any Chr(32, 13, 10)))
   If ff Then 函数声明 = Left(ss, ff) Else 函数声明 = ""
   
   ss = Trim(ss, Any Chr(32, 13, 10)) '头部
   
   Dim 函数名 As String, 函数定义 As String, 返回类型 As String, rr As String, 无符号 As String, 不可修改 As String
   Dim 方阔   As Long, 括号       As Long
   Do
      方阔 = 0
      For ff = Len(ss) To 1 Step -1
         If 方阔 = 2 Then
            If Mid(ss, ff, 1) = "[" Then 方阔 = 1
            Continue For
         End If
         If 方阔 = 1 Then
            If Mid(ss, ff, 1) = "]" Then
               方阔 = 2
            Else
               If Mid(ss, ff, 1) <> " " Then 方阔 = 0
            End If
            Continue For
         End If
         If 括号 = 1 Then
            If Mid(ss, ff, 1) = "(" Then Exit For
            Continue For
         End If
         If Mid(ss, ff, 1) = " " Then Exit For
         If Mid(ss, ff, 1) = "]" Then 方阔 = 2
         If Mid(ss, ff, 1) = "[" Then 方阔 = 1
         If Mid(ss, ff, 1) = ")" Then 括号 = 1
         
      Next
      
      'ff = InStrRev(ss, " ")
      If ff = 0 Then
         rr = ss
         ss = ""
      Else
         rr = Trim(Mid(ss, ff), Any Chr(32, 13, 10))
         ss = Trim(Left(ss, ff -1), Any Chr(32, 13, 10))
      end if
      If 函数名 = "" Then
         函数名 = rr
      Else
         If 返回类型 = "" Then
            返回类型 = rr
         Else
            If rr = "unsigned" Then 无符号   = "U"
            If rr = "const"    Then 不可修改 = "Const "
         End If
      End If
      If ff = 0 Then Exit Do
   Loop
   函数名 = YF_Replace(函数名, " ", "")
   If InStr("(+-*/-~`,.<>?/\{}!@#$%^&*(_+=-", Left(Trim(返回类型, Any Chr(32, 13, 10)), 1)) > 0 Or InStr("(+-*/-~`,.<>?/\{}!@#$%^&*(_+=-", Left(函数名, 1)) > 0 Then
      '前面字符 &= 返回类型
      返回类型 = ""
   Else
      
      返回类型 = Trim(返回类型, Any Chr(32, 13, 10))
   End If
   'Print 前面字符,函数名, 返回类型
   If 返回类型 = "" Then
      '只是一个普通的函数调用
      '前面字符 &= 函数名

      Dim kk As String = 前面字符 & "(" & 处理函数参数(参数列表) & ")"
      直接替换关键词(kk)
      新增翻译列表("函数", sci, sc代码, Len(B代码) + 1, kk)
      B代码 &= kk
      Return
   End If
   
   
   参数列表 = 处理参数列表(参数列表, "ByVal ")
   Do
      If Left(函数名, 1) <> "*" Then Exit Do
      函数名 = Mid(函数名, 2)
      If 返回类型 = "char" Then 返回类型 = "ZString"
      返回类型 &= " Ptr"
   Loop
   
   If Left(函数名, 1) = "("  Then 函数名 = Mid(函数名, 2)
   If Left(函数名, 1) = "*"  Then 函数名 = Mid(函数名, 2)
   If Right(函数名, 1) = ")" Then 函数名 = Left(函数名, Len(函数名) -1)
   If 返回类型 = "void" Then
      返回类型 = ""
      函数定义 = "Sub "
   Else
      函数定义 = "Function "
   End If
   If 返回类型 <> "" Then
      直接替换关键词(返回类型)
      返回类型 = "As " & 不可修改 & 无符号 & 返回类型
   End If
   'If Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
   If 等于后面 <> "" Then
             函数名 = YF_Replace(函数名, "]", ")")
            函数名= YF_Replace(函数名, "[", "(")
            函数名 = YF_Replace(函数名, ")(", ",")       
      新增翻译列表("函定", sci, sc代码, Len(B代码) + 1, 函数声明 & "Dim " & 函数名 & " As " & 函数定义 & "(" & 参数列表 & ")" & 返回类型 & 等于后面)
      B代码 &= 函数声明 & "Dim " & 函数名 & " As " & 函数定义 & "(" & 参数列表 & ")" & 返回类型 & 等于后面
    
   else
      新增翻译列表("函名", sci, sc代码, Len(B代码) + 1, 函数声明 & "Declare " & 函数定义 & 函数名 & "(" & 参数列表 & ")" & 返回类型 & 等于后面)
      B代码 &= 函数声明 & "Declare " & 函数定义 & 函数名 & "(" & 参数列表 & ")" & 返回类型 & 等于后面
   End If
End Sub
Sub 处理语句开始符号(ByRef ci As Long, C代码 As String, B代码 As String, 未处理代码 As String, 配对语句 As String)
   '{  // /*
   Dim ss  As String
   Dim sci As Long = ci, sc代码 As String
   Dim ff  as Long = InStr首字符查找倒查(0, 未处理代码, "=", 1)
   
   If ff > 0 And Mid(C代码, ci, 1) = "{" Then '是赋值
      ss         = Left(未处理代码, ff -1)
      sc代码     = 未处理代码
      sci        -= Len(sc代码)
      未处理代码 = Mid(未处理代码, ff)
      Dim 前面字符 As String
      前面字符 = LTrim(ss, Any Chr(32, 13, 10))
      ff       = Len(ss) - Len(前面字符)
      If ff Then 前面字符 = Left(ss, ff) Else 前面字符 = ""
      ss = Trim(ss, Any Chr(32, 13, 10))
      ss = 处理参数列表(ss, "")
      直接替换关键词(ss)
      'If Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
      If InStr(ss, " As ") Then
         ss = YF_Replace(ss, ")(", " -1,")
         'ss = YF_Replace(ss, ")", " -1)")
         新增翻译列表("变定", sci, sc代码, Len(B代码) + 1, 前面字符 & "Dim " & ss)
         B代码 &= 前面字符 & "Dim " & ss
      Else
         新增翻译列表("赋值", sci, sc代码, Len(B代码) + 1, 前面字符 & ss)
         B代码 &= 前面字符 & ss
      End If
      sci += Len(sc代码)
      ff  = InStr代码查找结束配对(ci + 1, C代码)
      If ff = 0 Then ff = Len(C代码) + 1
      '处理变量赋值部分
      sc代码     = 未处理代码 & Mid(C代码, ci, ff - ci + 1)
      未处理代码 = ""
      ss         = Trim(Mid(C代码, ci + 1, ff - ci -1), Any Chr(32, 13, 10))
      If ss <> "0" Then
         'ss = 处理函数参数(ss)
         直接替换关键词(ss)
         If Trim(前面字符,Any Chr(32, 13, 10)) = "" Then
            新增翻译列表("组赋", sci, sc代码, Len(B代码) + 1, " = {" & ss & "}")
            B代码 &=  " = {" & ss & "}"
            
         Else
            新增翻译列表("类赋", sci, sc代码, Len(B代码) + 1, " =Type(" & ss & ")")
            B代码 &= " =Type(" & ss & ")"
         EndIf
      End If
      ff = InStr首字符查找(ff + 1, C代码, "", 0)
      If ff = 0 Then ff = Len(C代码)
      ci = ff -1
      If Mid(C代码, ff, 2) = "//" Then '有注解
         ff  = InStr(ci, C代码, vbCrLf)
         sci = ci
         Dim 注解 As String
         If ff Then
            注解   = Mid(C代码, ci + 1, ff - ci -1)
            sc代码 = 注解
            处理单行中有注解(注解)
            ci = ff + 1
            新增翻译列表("注解", sci, sc代码, Len(B代码) + 1, 注解 & vbCrLf)
            B代码 &= 注解 & vbCrLf
         End If
      End If
      Return
   End If
   ff = InStr首字符查找倒查(0, 未处理代码, ")", 0)
   If ff = 0 Then
      未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
      Return
   End If
   ss         = 未处理代码
   sci        -= Len(ss) : sc代码 = ss
   未处理代码 = ""
   '函数需要从右到左分析才可以
   ff = InStr代码查找倒查(0, ss, ")")
   Dim 尾巴 As String
   
   If ff Then
      尾巴 = Mid(ss, ff + 1)
      ss   = Left(ss, ff -1)
   End If
   Dim 参数列表 As String
   ff = InStr代码查找倒查(0, ss, "(")
   If ff = 0 Then ff = 1
   参数列表 = Trim(Mid(ss, ff + 1), Any Chr(32, 13, 10))
   
   If 参数列表 = "void" Then
      参数列表 = ""
   Else
      参数列表 = 处理参数列表(参数列表, "ByVal ")
   End If
   Dim 前面字符 As String
   ss = Left(ss, ff -1)
   If InStr首字符查找倒查(0, ss, ",", 0) > 0 Or InStr首字符查找倒查(0, ss, "(", 0) > 0 Then
      '一个表达列表
      ff = InStr代码查找结束配对(ci + 1, C代码)
      If ff = 0 Then ff = Len(C代码) + 1
      前面字符   = ss
      ss         = Trim(Mid(C代码, ci + 1, ff - ci -1), Any Chr(32, 13, 10))
      ci         = ff
      未处理代码 = 前面字符 & " Type" & "(" & ss & ")"
      
      Return
   End If
   前面字符 = LTrim(ss, Any Chr(32, 13, 10))
   
   ff = Len(ss) - Len(前面字符)
   If ff Then 前面字符 = Left(ss, ff) Else 前面字符 = ""
   ss = Trim(ss, Any Chr(32, 13, 10)) '头部
   Dim 函数名 As String, 函数定义 As String, 返回类型 As String, rr As String, 无符号 As String, 不可修改 As String
   Do
      ff = InStrRev(ss, " ")
      If ff = 0 Then
         rr = ss
      Else
         rr = Trim(Mid(ss, ff + 1), Any Chr(32, 13, 10))
         ss = Trim(Left(ss, ff -1), Any Chr(32, 13, 10))
      End If
      If 函数名 = "" Then
         函数名 = rr
      Else
         If 返回类型 = "" Then
            返回类型 = rr
         Else
            If rr = "unsigned" Then 无符号   = "U"
            If rr = "const"    Then 不可修改 = "Const "
         End If
      End If
      If ff = 0 Then Exit Do
   Loop
   返回类型 = Trim(返回类型, Any Chr(32, 13, 10))
   If 函数名 = "" Then
      ff = InStr代码查找结束配对(ci + 1, C代码)
      If ff = 0 Then ff = Len(C代码) + 1
      ss = Trim(Mid(C代码, ci + 1, ff - ci -1), Any Chr(32, 13, 10))
      ci = ff   
      新增翻译列表("代码", sci, sc代码, Len(B代码) + 1, 前面字符 & " Type(" & ss & ")" & 尾巴)
      B代码 &= 前面字符 & " Type(" & ss & ")" & 尾巴
      Return
   End If
   Do
      If Left(函数名, 1) <> "*" Then Exit Do
      函数名 = Mid(函数名, 2)
      If 返回类型 = "char" Then 返回类型 = "ZString"
      返回类型 &= " Ptr"
   Loop
   
   If Left(函数名, 1) = "("  Then 函数名 = Mid(函数名, 2)
   If Left(函数名, 1) = "*"  Then 函数名 = Mid(函数名, 2)
   If Right(函数名, 1) = ")" Then 函数名 = Left(函数名, Len(函数名) -1)
   If 返回类型 = "void" Then
      返回类型 = ""
      函数定义 = "Sub "
      配对语句 &= "End Sub"
   Else
      函数定义 = "Function "
      配对语句 &= "End Function"
   End If
   
   If 返回类型 <> "" Then
      直接替换关键词(返回类型)
      返回类型 = "As " & 不可修改 & 无符号 & 返回类型
   End If
   直接替换关键词(参数列表)
   'If Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
   
   新增翻译列表("函始", sci, sc代码, Len(B代码) + 1, 前面字符 & 函数定义 & 函数名 & "(" & 参数列表 & ")" & 返回类型 & 尾巴)
   B代码 &= 前面字符 & 函数定义 & 函数名 & "(" & 参数列表 & ")" & 返回类型 & 尾巴
   
End Sub
Sub 处理条件IF(ByRef ci As Long, C代码 As String, B代码 As String, 配对语句 As String)
   'if ((text1 != NULL) && (text2 != NULL))
   Dim sci As Long = ci, sc代码 As String
   Dim ff As Long = InStr首字符查找(ci + 2, C代码, "", 0)

   If ff = 0 Then
      'If Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
      未处理代码处理(ci, B代码, StrToUtf8("If 语句错误，无法判断 "))
      ci = Len(C代码)
      Return
   End If
   Dim ff2 As Long = InStr空字符查找(ff, C代码, 1)
   Dim ss As String = Mid(C代码, ff, ff2 - ff+1)

   Dim 跨行 As String 
   sc代码 = Mid(C代码, ci, ff2 - ci )
   Dim 注解 As String
   ci = ff2
   ff = InStr首字符查找(ci + 1, C代码, "//", 0)
   If ff Then '有注解
      ff = InStr(ci + 1, C代码, vbCrLf)
      If ff = 0 Then ff = Len(C代码) + 1
      注解 = Mid(C代码, ci + 1, ff - ci -1)
      处理单行中有注解(注解)
      ci = ff + 1
      跨行 =" _ "
   End If
   ff = InStr首字符查找(ci + 1, C代码, "", 0)
   If ff = 0 Then ff = Len(C代码) + 1
   If Mid(C代码, ff, 1) <> "{" Then 
       If InStr(Mid(C代码,ci,ff-ci),vbCrLf) Then 跨行 =" _ "
      直接替换关键词(ss)
      新增翻译列表("IF单",sci, sc代码, Len(B代码) + 1, "If " & ss & " Then " & 跨行 & 注解 )
      B代码  &= "If " & ss & " Then " & 跨行 & 注解 
   Else
      '多行
      配对语句 &= "End If"
      'If Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
      直接替换关键词(ss)
      新增翻译列表("IF多",sci, sc代码, Len(B代码) + 1, "If " & ss & " Then " & 注解 )
      B代码 &= "If " & ss & " Then " & 注解 
      sc代码 &=Mid(C代码,ci,ff-ci)
      ci=ff 
   End If
   
End Sub
Sub 处理条件else(ByRef ci As Long, C代码 As String, B代码 As String, 配对语句 As String )
   'else
   Dim sci As Long = ci, sc代码 As String = "else"
   Dim ff  As Long = InStr空字符查找(ci, C代码, 0)
   新增翻译列表("else", sci, sc代码, Len(B代码) + 1, " Else ")
   B代码 &= " Else "
   ci    = ff
   ff    = InStr首字符查找(ci, C代码, "if", 0)
   If ff Then
      sc代码 = ""
      ci = ff 
      B代码 =RTrim(B代码)
      处理条件IF(ci, C代码, B代码, sc代码)
      
   End If
    
End Sub
Sub 处理return(ByRef ci As Long, C代码 As String, B代码 As String)
   'return result;
   Dim ff As Long = InStr代码查找(ci + 7, C代码, ";")
   If ff = 0 Then ff = Len(C代码) + 1
   Dim sci As Long =ci ,sc代码 As String =Mid(C代码, ci , ff - ci )
   Dim ss As String = Trim(Mid(C代码, ci + 7, ff - ci -7), Any Chr(32, 13, 10))

   ci = ff 
   ff = InStr(ci, C代码, vbCrLf)
   Dim 注解 As String
   If ff Then
      注解 = Mid(C代码, ci+1, ff - ci-1)
      处理单行中有注解(注解)
      ci = ff + 1
      注解 &=vbCrLf
   End If
    ss=C代码转换B代码(ss)
   'If Len(B代码) > 2 And Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
   新增翻译列表("返回",sci,sc代码,Len(B代码)+1,"Return " & ss  & 注解 ) 
   B代码 &= "Return " & ss  & 注解
End Sub
Sub 处理while(ByRef ci As Long, C代码 As String, B代码 As String, 配对语句 As String)
   'while (!WindowShouldClose())
   Dim ff As Long = InStr首字符查找(ci + 5, C代码, "", 0)
   If ff = 0 Then
      'If Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
      未处理代码处理(ci, B代码, StrToUtf8("while 语句错误，无法判断 ("))
      ci = Len(C代码)
      Return
   End If
   Dim ff2 As Long = InStr空字符查找(ff , C代码, 1)

   Dim ss  As String = Mid(C代码, ff , ff2 - ff )
   Dim sci As Long   = ci, sc代码 As String =  Mid(C代码, ci , ff2 - ci )
   ci = ff2
   ff = InStr首字符查找(ci + 1, C代码, "//", 0)
   
   Dim 注解 As String
   If ff Then
      ff = InStr(ff + 2, C代码, vbCrLf)
      If ff = 0 Then ff = Len(C代码) + 1
      注解 = Mid(C代码, ci + 1, ff - ci -1)
      处理单行中有注解(注解)
      注解 &= vbCrLf
      ci   = ff + 1
   End If
   直接替换关键词(ss)
   ff2 = InStr首字符查找(ci + 1, C代码, "{", 0)
   If ff2 = 0 Then
      '估计是单行模式
      ff2 = InStr代码查找(ci + 1, C代码, ";")
      If ff2 = 0 Then ff2 = Len(C代码) + 1
      Dim pp As String
      pp = Mid(C代码, ci + 1, ff2 - ci -1)
      ci = ff2
      新增翻译列表("Wh1",sci, sc代码, Len(B代码) + 1, "While " & ss & " : " & pp & " : Wend " & 注解)
      B代码 &= "While " & ss & " : " & pp & " : Wend " & 注解
      
      Return
   end if
   ci = ff2
   
   'If Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
   新增翻译列表("Wh2",sci, sc代码, Len(B代码) + 1, "While " & ss & 注解)
   B代码    &= "While " & ss & 注解
   配对语句 &= "End Wend"
   
End Sub

Sub 处理循环FOR(ByRef ci As Long, C代码 As String, B代码 As String, 配对语句 As String)
   'for (int i = 0; i < size;)
   Dim ff As Long = InStr首字符查找(ci + 3, C代码, "(", 0)
   If ff = 0 Then
      'If Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
      未处理代码处理(ci, B代码, StrToUtf8("For 语句错误，无法判断 ("))
      ci = Len(C代码)
      Return
   End If
   Dim ff2 As Long = InStr代码查找(ff + 1, C代码, ")")
   If ff2 = 0 Then
      未处理代码处理(ci, B代码, StrToUtf8("for 语句错误，无法判断 )"))
      ci = Len(C代码)
      Return
   End If
   Dim ss  As String = Mid(C代码, ff + 1, ff2 - ff - 1)
   Dim sci As Long   = ci, sc代码 As String = Mid(C代码, ci, ff2 - ci + 1)
   
   ci = ff2
   Dim 欠 As String,连续声明 As String 
   ff = InStr首字符查找(ci + 1, C代码, "", 0)
   If ff = 0 Then ff = Len(C代码) + 1
   If Mid(C代码, ff, 1) = "{" Then
      ci = ff -1
   Else
      欠 = "*" '欠一个，等遇到}再还
   End If
   
   ff = InStr(ss, ";")
   Dim pp As String = "For "
   Dim bb As String
   If ff Then
      bb = Left(ss, ff -1)
      ss = Mid(ss, ff + 1)
      bb = 处理参数列表(bb, "")
      ff = InStr代码查找(1,bb, ",",0)
      If ff Then '有连续声明
         ff = InStr(bb, " As ")
         pp = Left(bb, ff -1)
         变量列表连续变量 bb
         pp = "Scope " & vbCrLf & "Dim " & bb & vbCrLf &  "For " & pp & " To "
         连续声明 = "End Scope" & 欠
         欠 ="*"
      Else
         pp &= bb & " To "
      End If
      
   End If
   ff = InStr(ss, ";")
   If ff Then
      bb = Left(ss, ff -1)
      ss = Mid(ss, ff + 1)
      ff = InStrRev(bb, "=")
      If ff Then
         bb = Mid(bb, ff + 1)
      Else
         ff = InStr(bb, "<")
         If ff Then
            bb = Mid(bb, ff + 1) & " - 1"
         Else
            ff = InStr(bb, ">")
            If ff Then bb = Mid(bb, ff + 1) & " + 1"
         End If
      End If
      pp &= bb
   End If
   ss = Trim(ss, Any " " & vbCrLf)
   If Right(ss, 2) = "++" Or Left(ss, 2) = "++" Then ss = ""
   If Right(ss, 2) = "--" Or Left(ss, 2) = "--" Then ss = "-1"
   If Len(ss) Then pp &= " Step " & ss
   直接替换关键词(pp)
   新增翻译列表("F循", sci, sc代码, Len(B代码) + 1, pp)
   B代码 &= pp
   If 欠 = "*" Then
      ff = InStr代码查找(ci + 1, C代码, ";", 1)
      If ff Then
         ss = Mid(C代码, ci + 1, ff - ci)
         If InStr(ss, vbCrLf) = 0 Then
            '单行内容
            sci    = ci
            sc代码 = ss
            ci     = ff
            ss = C代码转换B代码(ss)
            ss = " : " & ss & " : Next"
            If 连续声明<>"" Then 
                ss &=vbCrLf & "End Scope"
            End If 
            新增翻译列表("单循", sci, sc代码, Len(B代码) + 1,ss )
            B代码 &= ss
            Return
         End If
      End If
   End If
   
   配对语句 &=连续声明 & "End Next" & 欠
   
End Sub
Sub 处理三元运算符(ByRef ci As Long, C代码 As String, B代码 As String, 未处理代码 As String)
   '
   Dim ff   as Long = InStr首字符查找倒查(0, 未处理代码, ")", 0)
   Dim 条件 As String, 前部 As String
   Dim sci  As Long   = ci - Len(未处理代码), sc代码 As String = 未处理代码
   Dim ss   As String = RTrim(未处理代码, Any Chr(10, 13, 32))
   
   If ff = 0 Then
      '此条件不带括号
      ff   = InStr非关键词倒查(0, ss)
      前部 = Left(ss, ff)
      条件 = Mid(ss, ff + 1)
      前部 = RTrim(前部, Any Chr(10, 13, 32))
      If Right(前部, 2) = "==" Or Right(前部, 2) = "!=" Or Right(前部, 1) = "<" Or Right(前部, 1) = ">" Or Left(LTrim(前部, Any Chr(10, 13, 32)), 1) = "!" Or _
         Right(前部, 2) = "<=" Or Right(前部, 2) = ">=" Or Right(前部, 2) = "&&" Or Right(前部, 2) = "||" Then
            ff = InStr关键词倒查(0, 前部)
         条件 = Mid(前部, ff + 1) & " " & 条件
         前部 = Left(前部, ff)
         前部 = RTrim(前部, Any Chr(10, 13, 32))
         ff   = InStr非关键词倒查(0, 前部)
         条件 = Mid(前部, ff + 1) & " " & 条件
         前部 = Left(前部, ff)
      End If
   Else
      '条件带括号
      条件 = Left(未处理代码, ff -1)
      ff   = InStr代码查找倒查(0, 条件, "(", 0)
      前部 = Left(条件, ff -1)
      条件 = Mid(条件, ff + 1) '获取到条件表达式
      ff   = InStr首字符查找倒查(0, 前部, "", 0)
      'Print 前部, 条件
      If ff Then
         If InStr("_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", Mid(前部, ff, 1)) > 0 Then
            条件 = Mid(前部, ff + 1) & "(" & 条件 & ")"
            前部 = Left(前部, ff)
            ff   = InStr非关键词倒查(0, 前部)
            条件 = Mid(前部, ff + 1) & 条件
            前部 = Left(前部, ff)
         End If
      Else
         条件 = "(" & 条件 & ")"
      End If
      
   End If
   
   Dim 表达式a As String, 表达式b As String
   ff = InStr代码查找(ci + 1, C代码, ":", 1)
   If ff = 0 Then ff = Len(C代码) + 1
   表达式a = Mid(C代码, ci + 1, ff - ci -1)
   sc代码  &= Mid(C代码, ci, ff - ci)
   ci      = ff
   ff      = InStr代码查找(ci + 1, C代码, ";", 1)
   If ff = 0 Then ff = Len(C代码) + 1
   表达式b = Mid(C代码, ci + 1, ff - ci -1)
   sc代码  &= Mid(C代码, ci, ff - ci)
   ci      = ff -1
     '表达式a = C代码转换B代码(表达式a)
     '表达式b = C代码转换B代码(表达式b)
     '直接替换关键词(前部)
     '直接替换关键词(条件)
     '新增翻译列表("三元", sci, sc代码, Len(B代码) + 1, 前部 & "IIf(" & 条件 & "," & 表达式a & "," & 表达式b & ")")
     'B代码      &= 前部 & "IIf(" & 条件 & "," & 表达式a & "," & 表达式b & ")"
   未处理代码 = 前部 & "IIf(" & 条件 & "," & 表达式a & "," & 表达式b & ")"
   
End Sub
Sub 处理switch(ByRef ci As Long, C代码 As String, B代码 As String, 配对语句 As String)
   'switch(a)
   Dim ff As Long = InStr首字符查找(ci + 6, C代码, "", 0)
   If ff = 0 Then
      'If Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
      未处理代码处理(ci, B代码, StrToUtf8("switch 语句错误，无法判断 "))
      ci = Len(C代码)
      Return
   End If
   Dim ff2 As Long = InStr空字符查找(ff , C代码, 1)
   
   Dim ss  As String = Mid(C代码, ff, ff2 - ff+1)
   Dim sci As Long   = ci, sc代码 As String =  Mid(C代码, ci, ff2 - ci)
   ci = ff2
   ff = InStr首字符查找(ci + 1, C代码, "//", 0)
   
   Dim 注解 As String
   If ff Then
      ff = InStr(ff + 2, C代码, vbCrLf)
      If ff = 0 Then ff = Len(C代码) + 1
      注解 = Mid(C代码, ci + 1, ff - ci -1)
      处理单行中有注解(注解)
      注解 &= vbCrLf
      ci   = ff + 1
   End If
   直接替换关键词(ss)
   ff = InStr首字符查找(ci + 1, C代码, "{", 0)
   If ff = 0 Then ff = Len(C代码)
   ci = ff
   
   'If Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
   新增翻译列表("swit", sci, sc代码, Len(B代码) + 1, "Select Case " & ss & 注解)
   B代码    &= "Select Case " & ss & 注解
   配对语句 &= "End Select"
End Sub
Sub 处理case(ByRef ci As Long, C代码 As String, B代码 As String)
   'case 1:printf("Monday\n");
   Dim ff As Long = InStr代码查找(ci + 4, C代码, ":", 0)
   If ff = 0 Then ff = Len(C代码) + 1
   Dim sci As Long = ci, sc代码 As String = Mid(C代码, ci, ff - ci)
   ci += 4
   Dim 条件 As String = Trim(Mid(C代码, ci, ff - ci), Any Chr(32, 13, 10))
   ci = ff
   ff = InStr首字符查找(ci + 1, C代码, "//", 0)
   Dim 注解 As String
   If ff Then
      ff = InStr(ff + 2, C代码, vbCrLf)
      If ff = 0 Then ff = Len(C代码) + 1
      sc代码 &=Mid(C代码, ci , ff - ci )
      注解 = Mid(C代码, ci + 1, ff - ci -1)
      处理单行中有注解(注解)
      注解 &= vbCrLf
      sc代码 &=vbCrLf
      ci   = ff + 1
   End If
   直接替换关键词(条件)
   ff =InStr代码查找(ci + 1, C代码, ";", 0)
   If ff = 0 Then ff = Len(C代码) + 1
   Dim 语句 As String = Mid(C代码, ci+1, ff - ci-1)
   If InStr(语句,vbCrLf)>0 Or 注解<>"" Then 语句="" Else 语句=vbCrLf
   'If Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
   新增翻译列表("Case", sci, sc代码, Len(B代码) + 1, "Case " & 条件 & 注解  & 语句 )
   B代码    &= "Case " & 条件 & 注解  & 语句 

End Sub
Sub 处理break(ByRef ci As Long, C代码 As String, B代码 As String, 配对语句 As String)
   'break;
   '处于某个循环内，就要跳出某个循环
   Dim ff As Long = InStr代码查找(ci + 5, C代码, ";", 0)
   If ff = 0 Then ff = Len(C代码) + 1
   Dim sci As Long = ci, sc代码 As String = Mid(C代码, ci, ff - ci)
   ci = ff
   Dim ss As String = 配对语句
   ff = InStrRev(ss, "End ")
   If ff Then
      Dim pp As String = Mid(ss, ff)
      Do
         If pp = "" Then Exit Do
         If pp <> "End If" And pp <> "End If*" Then Exit Do
         ss = Left(ss, ff -1)
         ff = InStrRev(ss, "End ")
         If ff = 0 Then pp = "" : Exit Do
         pp = Mid(ss, ff)
      Loop
      If pp = "End Select" Then Return
      If pp = "End Next" Then
         新增翻译列表("Exit", sci, sc代码, Len(B代码) + 1,"Exit For")
         B代码 &= "Exit For" 
         Return 
      End If
      If pp = "End Wend" Then
         新增翻译列表("Exit", sci, sc代码, Len(B代码) + 1,"Exit While")
         B代码 &= "Exit While" 
         Return 
      End If  
      If pp = "End Loop" Then
         新增翻译列表("Exit", sci, sc代码, Len(B代码) + 1,"Exit Do")
         B代码 &= "Exit Do" 
         Return 
      End If           
   End If
   '"End Select""End Union""End Type""End If" "End Wend""End Next""End Sub""End Wend""End Extern"
   
   
End Sub
Sub 处理default(ByRef ci As Long, C代码 As String, B代码 As String)
   'default:
   Dim ff As Long = InStr代码查找(ci + 7, C代码, ":", 0)
   If ff = 0 Then ff = Len(C代码) + 1
   Dim sci As Long = ci, sc代码 As String = Mid(C代码, ci, ff - ci)
   ci = ff
   ff = InStr首字符查找(ci + 1, C代码, "//", 0)
   Dim 注解 As String
   If ff Then
      ff = InStr(ff + 2, C代码, vbCrLf)
      If ff = 0 Then ff = Len(C代码) + 1
      sc代码 &=Mid(C代码, ci , ff - ci )
      注解 = Mid(C代码, ci + 1, ff - ci -1)
      处理单行中有注解(注解)
      注解 &= vbCrLf
      sc代码 &=vbCrLf
      ci   = ff + 1
   End If

   ff =InStr代码查找(ci + 1, C代码, ";", 0)
   If ff = 0 Then ff = Len(C代码) + 1
   Dim 语句 As String = Mid(C代码, ci+1, ff - ci-1)
   If InStr(语句,vbCrLf)>0 Or 注解<>"" Then 语句="" Else 语句=vbCrLf

   新增翻译列表("defa", sci, sc代码, Len(B代码) + 1, "Case Else" &  注解  & 语句 )
   B代码    &= "Case Else" &  注解  & 语句 

End Sub
Sub 处理union(ByRef ci As Long, C代码 As String, B代码 As String)
   'union Data
   Dim ff As Long = InStr代码查找(ci + 5, C代码, "{")
   If ff = 0 Then ff = Len(C代码) + 1
   Dim ff2 As Long = InStr代码查找(ci + 5, C代码, ";")
   If ff2 = 0 Then ff2 = Len(C代码) + 1
   Dim ss As String '= Trim(Mid(C代码, ci + 6, ff - ci -6), Any Chr(32, 13, 10))
   If ff2 < ff Then '遇到;先，就表示是 定义
      Dim sci As Long = ci, sc代码 As String = Mid(C代码, ci, ff2 - ci + 1)
      ss = Trim(Mid(C代码, ci + 5, ff2 - ci -5), Any Chr(32, 13, 10))
      ci = ff2 + 1
      ss = 处理参数列表(ss, "")
      变量列表连续变量(ss)
      直接替换关键词(ss)
      ss  = YF_Replace(ss, ")", " -1)")
      ff2 = InStr(ci, C代码, vbCrLf)
      Dim 注解 As String
      If ff2 Then
         注解   = Mid(C代码, ci, ff2 - ci)
         sc代码 &= 注解
         处理单行中有注解(注解)
         ci   = ff2 + 1
         注解 &= vbCrLf
      End If
      
      'If Len(B代码)>2 And Right(B代码, 2) <> vbCrLf Then B代码 &= vbCrLf
      新增翻译列表("共定", sci, sc代码, Len(B代码) + 1, "Dim " & ss & 注解)
      B代码 &= "Dim " & ss & 注解
      Return
   End If
   Dim sci As Long = ci, sc代码 As String = Mid(C代码, ci, ff - ci)
   ss = Trim(Mid(C代码, ci + 6, ff - ci -6), Any Chr(32, 13, 10))
   ci = ff + 1
   Dim 类名   As String = ss
   Dim 尾巴注解 As String
   ff = InStr代码查找结束配对(ci, C代码)
   If ff = 0 Then ff = Len(C代码) + 1
   ss     = Mid(C代码, ci, ff - ci) '这是中间代码
   sc代码 &= Mid(C代码, ci, ff - ci + 1)
   ci     = ff + 1
   ff     = InStr(ci, C代码, ";")
   If ff Then
      sc代码 &= Mid(C代码, ci, ff - ci + 1)
      ci     = ff + 1
   End If
   ff = InStr代码查找注解(ci, C代码)
   If ff Then
      Dim ff2 As Long = InStr(ff + 2, C代码, vbCrLf)
      If ff2 = 0 Then ff2 = Len(C代码) + 1
      尾巴注解 = Trim(Mid(C代码, ff + 2, ff2 - ff -2), Any Chr(32, 13, 10))
      sc代码   &= Mid(C代码, ff, ff2 - ff)
      尾巴注解 = "' " & 翻译英文注解(尾巴注解) & vbCrLf
      ci       = ff2 + 1
   End If
   'SaveFileStr(App.Path & "x" & 类名 & ".txt",ss)
   Dim 类内容 As String, sti As Long = 1, 空 As Long
   For si As Long = 1 To Len(ss)
      If Mid(ss, si, 1) = ";" Then
         If Len(类内容) Then 类内容 &= vbCrLf
         Dim 参数 As String = Mid(ss, sti, si - sti)
         参数=Trim(参数,Any Chr(32,10,13))
         参数 = 处理参数列表(参数, "")
         变量列表连续变量(参数)
         直接替换关键词(参数)
         类内容 &= Space(空) & 参数 ' 变量定义处理(Mid(ss, sti, si - sti))
         sti    = si + 1
         空     = 0
         Continue For
      End If
      If Mid(ss, si, 2) = vbCrLf Then
         'If Len(类内容) Then 类内容 &= vbCrLf
         si += 1
         空 = 0
         Continue For
      End If
      If Mid(ss, si, 2) = "//" Then
         ff = InStr(si + 2, ss, vbCrLf)
         If ff = 0 Then ff = Len(ss)
         Dim tt As String = Mid(ss, si + 2, ff - si -2)
         If tt <> "" Then 类内容 &= Space(空) & "'" & 翻译英文注解(tt)
         si  = ff + 2
         sti = si
         空  = 0
         Continue For
      End If
      If Mid(ss, si, 1) = " " Then 空 += 1
   Next
   Dim sbi As Long = Len(B代码) + 1, sb代码 As String
   sb代码 = "Union " & 类名 & vbCrLf & 类内容 & vbCrLf & Space(空) & "End Union"
   B代码  &= sb代码
   新增翻译列表("共用", sci, sc代码, sbi, sb代码)
   
End Sub

